package com.ruoyi.common.utils;
import org.lionsoul.ip2region.xdb.Searcher;

public class IpTest {
    private static final String XDB_PATH = "C:/Users/lieyou/Desktop/zhs/ruoyi/zhs-mall/mall-common/src/main/resources/test/ip2region.xdb";

    public static String getRegion(String ip){
        try {
            // 创建一个基于文件的 Searcher 对象
            Searcher searcher = Searcher.newWithFileOnly(XDB_PATH);
            String region = searcher.search(ip);
            return region;
            // 关闭 Searcher
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    //116.25.39.57 深圳
    //115.159.0.1 上海
    //114.114.114.114 南京市
    //61.144.56.100 广州市
    //219.142.99.8 北京
    //114.24.0.1 台湾
    public static void main(String[] args) {
        System.out.println(getRegion("223.104.68.210"));
    }
}
